/**
 * 
 */
package lu.med.praxiswahl.wahlumed.client.utilities;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 * @author PatrickPierre
 * 
 */
public class JlistCellRenderer extends JLabel implements ListCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7849840071021035163L;

	private Font bold = new Font("Verdana", Font.BOLD, 11);

	public JlistCellRenderer() {
	}

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		String val = (String) value;
		String[] splitedVal = val.split(";");
		String matricule = splitedVal[0];
		String name = splitedVal[1];
		
		this.setOpaque(true);

//		this.setText("<html><b>" + (String) value + "</html>");
		this.setText("<html><b>" + matricule+"</b><br />" +name+ "<br /><br /></html>");
		this.setFont(new Font("Verdana", Font.PLAIN, 11));

		if (isSelected) {
			this.setBackground(Color.blue);
			this.setForeground(Color.WHITE);
			setFont(bold);
			this.setBorder(BorderFactory.createLineBorder(Color.blue));

		} else {
			this.setBackground(Color.white);
			this.setForeground(Color.black);
			this.setBorder(null);
		}
		
		return this;
	}

}
